﻿using SDF.Core.Infrastructure;
using SDF.Plugin.Misc.SAPAdapter.Extensions;
using SDF.Plugin.Misc.SAPAdapter.Models;
using SDF.Plugin.Misc.SAPAdapter.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SDF.Plugin.Misc.SAPAdapter.Controllers.Version1
{
    public class GetTableDataController : SAPWebApiBase
    {
        ISAPConnectorService _sapService;

        GetTableDataController()
        {
            _sapService = EngineContext.Current.Resolve<ISAPConnectorService>();
        }

        public IEnumerable<Dictionary<string, string>> Post(TableDataAPIModel model)
        {
            return _sapService.GetTableData(model.SAPInstance, model.TableName, model.ToRfcReadTableParamsModel());
        }
    }
}